//
//  RYWupingView.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2021/1/13.
//  Copyright © 2021 叁拾叁. All rights reserved.
//

import UIKit
import YYText

class RYWupingView: SYBaseView {

    let name: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x1D1D1D)
        v.font = 16.autoFontSize()
        
        
        return v
    }()
    
    let dijia: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        v.text = "认养地价"
        
        return v
    }()
    
    let changliang: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        v.text = "保底产量"
        
        return v
    }()
    
    let zhouqi: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        v.text = "生长周期"
        
        return v
    }()
    
    let dijiaDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        
        
        return v
    }()
    
    let changliangDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        
        
        return v
    }()
    
    let zhouqiDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        v.text = "生长周期"
        
        return v
    }()
    
    let pic: UIImageView = {
        let v: UIImageView = UIImageView()
        
        return v
    }()
    
    func configure(_ model: RYProductDetailModel) {
        name.text = model.name
        let d: Double = Double(model.adoptPrice ?? "0") ?? 0.0
        let priceStr = String(format: "%.2f", d)
        dijiaDetail.text = "\(priceStr)元/\(model.adoptPart ?? "")"
        changliangDetail.text = model.adoptHarvest
        
        let begain = model.productionCycleBegin?.replacingOccurrences(of: "-", with: ".") ?? ""
        let end = model.productionCycleEnd?.replacingOccurrences(of: "-", with: ".") ?? ""
        zhouqiDetail.text = begain + "-" + end
        
        let urls = model.carouselImgUrl?.components(separatedBy: ",")
        let url = "\(IP) + \(urls?.first ?? "")"
        pic.kf.setImage(with: URL(string: url))
    }
    
    override func initViews() {
        
        addSubview(name)
        addSubview(dijia)
        addSubview(changliang)
        addSubview(zhouqi)
        addSubview(dijiaDetail)
        addSubview(changliangDetail)
        addSubview(zhouqiDetail)
        addSubview(pic)
        pic.snp.makeConstraints { (make) in
            make.bottom.top.equalToSuperview()
            make.left.equalToSuperview().offset(15.autoWidth())
            make.width.height.equalTo(100.autoWidth())
        }
        name.snp.makeConstraints { (make) in
            make.top.equalTo(pic).offset(3.autoWidth())
            make.left.equalTo(pic.snp.right).offset(8.autoWidth())
            make.height.equalTo(16.autoWidth())
        }
        dijia.snp.makeConstraints { (make) in
            make.top.equalTo(name.snp.bottom).offset(15.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        changliang.snp.makeConstraints { (make) in
            make.top.equalTo(dijia.snp.bottom).offset(13.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        zhouqi.snp.makeConstraints { (make) in
            make.top.equalTo(changliang.snp.bottom).offset(13.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        
        dijiaDetail.snp.makeConstraints { (make) in
            make.top.equalTo(name.snp.bottom).offset(15.autoWidth())
            make.left.equalTo(name).offset(60.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
        changliangDetail.snp.makeConstraints { (make) in
            make.top.equalTo(dijia.snp.bottom).offset(13.autoWidth())
            make.left.equalTo(name).offset(60.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
        zhouqiDetail.snp.makeConstraints { (make) in
            make.top.equalTo(changliang.snp.bottom).offset(13.autoWidth())
            make.left.equalTo(name).offset(60.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
    }

}





class RYQuerenWupingView: SYBaseView {

    let name: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x1D1D1D)
        v.font = 16.autoFontSize()
        
        return v
    }()
    
    let dijia: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        v.text = "描述"
        
        return v
    }()
    
    let changliang: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        v.text = "收获"
        
        return v
    }()
    
    let dijiaDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        
        
        return v
    }()
    
    let changliangDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        
        
        return v
    }()
    
    let zhouqiDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        
        
        return v
    }()
    
    let pic: UIImageView = {
        let v: UIImageView = UIImageView()
        
        v.layer.cornerRadius = 3
        return v
    }()
    
    let zhouqi: YYLabel = {
        let v:YYLabel = YYLabel()
        v.textColor = UIColor(hex: 0x1D1D1D)
        v.font = 16.autoFontSize()
        
        
        return v
    }()
    
    func configure(_ model: RYProductDetailModel, _ num: Int) {
        name.text = model.name
        
        dijiaDetail.text = model.description
        changliangDetail.text = model.adoptHarvest
        
        zhouqiDetail.text = "X \(num)份"
        
        let urls = model.carouselImgUrl?.components(separatedBy: ",")
        let url = "\(IP) + \(urls?.first ?? "")"
        pic.kf.setImage(with: URL(string: url))
        
        zhouqi.attributedText = self.setPriceLb(model.adoptPrice)
    }
    
    override func initViews() {
        
        
        addSubview(name)
        addSubview(dijia)
        addSubview(changliang)
        addSubview(zhouqi)
        addSubview(dijiaDetail)
        addSubview(changliangDetail)
        addSubview(zhouqiDetail)
        addSubview(pic)
        pic.snp.makeConstraints { (make) in
            make.bottom.top.equalToSuperview()
            make.left.equalToSuperview().offset(15.autoWidth())
            make.width.height.equalTo(100.autoWidth())
        }
        name.snp.makeConstraints { (make) in
            make.top.equalTo(pic).offset(3.autoWidth())
            make.left.equalTo(pic.snp.right).offset(8.autoWidth())
            make.height.equalTo(16.autoWidth())
        }
        dijia.snp.makeConstraints { (make) in
            make.top.equalTo(name.snp.bottom).offset(15.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        changliang.snp.makeConstraints { (make) in
            make.top.equalTo(dijia.snp.bottom).offset(13.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        zhouqi.snp.makeConstraints { (make) in
            make.top.equalTo(changliang.snp.bottom).offset(13.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        
        dijiaDetail.snp.makeConstraints { (make) in
            make.top.equalTo(name.snp.bottom).offset(15.autoWidth())
            make.left.equalTo(name).offset(60.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
        changliangDetail.snp.makeConstraints { (make) in
            make.top.equalTo(dijia.snp.bottom).offset(13.autoWidth())
            make.left.equalTo(name).offset(60.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
        zhouqiDetail.snp.makeConstraints { (make) in
            make.top.equalTo(changliang.snp.bottom).offset(13.autoWidth())
            make.right.equalToSuperview().offset(-15.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
    }

}


class RYDingdanWupingView: SYBaseView {

    let name: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x1D1D1D)
        v.font = 16.autoFontSize()
        
        return v
    }()
    
    let dijia: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        v.text = "认购数量"
        
        return v
    }()
    
    let changliang: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        v.text = "配送次数"
        
        return v
    }()
    
    let dijiaDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        
        
        return v
    }()
    
    let changliangDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        
        
        return v
    }()
    
    let zhouqiDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        
        
        return v
    }()
    
    let pic: UIImageView = {
        let v: UIImageView = UIImageView()
        
        v.layer.cornerRadius = 3
        return v
    }()
    
    let zhouqi: YYLabel = {
        let v:YYLabel = YYLabel()
        v.textColor = UIColor(hex: 0x1D1D1D)
        v.font = 16.autoFontSize()
        
        
        return v
    }()
    
    func configure(_ model: RYDingdanModel) {
        name.text = "\(model.adoptFarmProductVO?.name ?? "")"

        dijiaDetail.text = "\(model.adoptFarmProductVO?.adoptedNum ?? 0)\(model.adoptFarmProductVO?.adoptHarvestUnit ?? "") （\(model.adoptFarmProductVO?.adoptHarvest ?? "")）"
        changliangDetail.text = model.deliveryCycleName

        zhouqiDetail.text = "X \(model.orderQuantity ?? 0)份"
        
        let urls = model.adoptFarmProductVO?.carouselImgUrl?.components(separatedBy: ",")
        let url = "\(IP) + \(urls?.first ?? "")"
        pic.kf.setImage(with: URL(string: url))

        let price: String = "\(model.adoptFarmProductVO?.adoptPrice ?? 0)"
        zhouqi.attributedText = self.setPriceLb(price)
    }
    
    override func initViews() {
        
        
        addSubview(name)
        addSubview(dijia)
        addSubview(changliang)
        addSubview(zhouqi)
        addSubview(dijiaDetail)
        addSubview(changliangDetail)
        addSubview(zhouqiDetail)
        addSubview(pic)
        pic.snp.makeConstraints { (make) in
            make.bottom.top.equalToSuperview()
            make.left.equalToSuperview().offset(15.autoWidth())
            make.width.height.equalTo(100.autoWidth())
        }
        name.snp.makeConstraints { (make) in
            make.top.equalTo(pic).offset(3.autoWidth())
            make.left.equalTo(pic.snp.right).offset(8.autoWidth())
            make.height.equalTo(16.autoWidth())
        }
        dijia.snp.makeConstraints { (make) in
            make.top.equalTo(name.snp.bottom).offset(15.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        changliang.snp.makeConstraints { (make) in
            make.top.equalTo(dijia.snp.bottom).offset(13.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        zhouqi.snp.makeConstraints { (make) in
            make.top.equalTo(changliang.snp.bottom).offset(13.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        
        dijiaDetail.snp.makeConstraints { (make) in
            make.top.equalTo(name.snp.bottom).offset(15.autoWidth())
            make.left.equalTo(name).offset(60.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
        changliangDetail.snp.makeConstraints { (make) in
            make.top.equalTo(dijia.snp.bottom).offset(13.autoWidth())
            make.left.equalTo(name).offset(60.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
        zhouqiDetail.snp.makeConstraints { (make) in
            make.top.equalTo(changliang.snp.bottom).offset(13.autoWidth())
            make.right.equalToSuperview().offset(-15.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
    }

}



class RYDingdanWupingListView: SYBaseView {

    let name: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x1D1D1D)
        v.font = 16.autoFontSize()
        
        return v
    }()
    
    let dijia: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        v.text = "认购数量"
        
        return v
    }()
    
    let changliang: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        v.text = "配送次数"
        
        return v
    }()
    
    let dijiaDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        
        
        return v
    }()
    
    let changliangDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        
        
        return v
    }()
    
    let bianhao: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        return v
    }()
    
    let zhouqiDetail: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        
        
        return v
    }()
    
    let pic: UIImageView = {
        let v: UIImageView = UIImageView()
        
        v.layer.cornerRadius = 3
        return v
    }()
    
    let zhouqi: YYLabel = {
        let v:YYLabel = YYLabel()
        v.textColor = UIColor(hex: 0x1D1D1D)
        v.font = 16.autoFontSize()
        
        
        return v
    }()
    
    func configure(_ model: RYDingdanListModel) {
        name.text = "\(model.adoptFarmProductVO?.name ?? "")"

        dijiaDetail.text = "\(model.adoptFarmProductVO?.adoptedNum ?? 0)\(model.adoptFarmProductVO?.adoptHarvestUnit ?? "") （\(model.adoptFarmProductVO?.adoptHarvest ?? "")）"
        changliangDetail.text = model.deliveryCycleName

        zhouqiDetail.text = "X \(model.orderQuantity)份"
        
        let urls = model.adoptFarmProductVO?.carouselImgUrl?.components(separatedBy: ",")
        let url = "\(IP) + \(urls?.first ?? "")"
        pic.kf.setImage(with: URL(string: url))

        zhouqi.text = String(format: "￥%.2f", model.adoptFarmProductVO?.adoptPrice ?? 0.0)
        bianhao.text = "编号\(model.adoptFarmProductVO?.serialNumber ?? "")"
    }
    
    override func initViews() {
        
        
        addSubview(name)
        addSubview(dijia)
        addSubview(changliang)
        addSubview(zhouqi)
        addSubview(dijiaDetail)
        addSubview(changliangDetail)
        addSubview(zhouqiDetail)
        addSubview(pic)
        addSubview(bianhao)
        pic.snp.makeConstraints { (make) in
            make.bottom.top.equalToSuperview()
            make.left.equalToSuperview().offset(15.autoWidth())
            make.width.height.equalTo(100.autoWidth())
        }
        name.snp.makeConstraints { (make) in
            make.top.equalTo(pic).offset(3.autoWidth())
            make.left.equalTo(pic.snp.right).offset(8.autoWidth())
            make.height.equalTo(16.autoWidth())
        }
        dijia.snp.makeConstraints { (make) in
            make.top.equalTo(name.snp.bottom).offset(5.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        changliang.snp.makeConstraints { (make) in
            make.top.equalTo(dijia.snp.bottom).offset(5.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        bianhao.snp.makeConstraints { (make) in
            make.top.equalTo(changliang.snp.bottom).offset(5.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        zhouqi.snp.makeConstraints { (make) in
            make.top.equalTo(bianhao.snp.bottom).offset(13.autoWidth())
            make.left.equalTo(name)
            make.height.equalTo(13.autoWidth())
        }
        
        dijiaDetail.snp.makeConstraints { (make) in
            make.top.equalTo(name.snp.bottom).offset(5.autoWidth())
            make.left.equalTo(name).offset(60.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
        changliangDetail.snp.makeConstraints { (make) in
            make.top.equalTo(dijia.snp.bottom).offset(5.autoWidth())
            make.left.equalTo(name).offset(60.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
        zhouqiDetail.snp.makeConstraints { (make) in
            make.top.equalTo(bianhao.snp.bottom).offset(13.autoWidth())
            make.right.equalToSuperview().offset(-15.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
    }

}
